package com.glsc.ngateway.common.base.repo.mysql.cmdb;

import com.glsc.ngateway.common.base.domain.mysql.cmdb.CmdbDiskStandardDeviceStandardRelate;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.stereotype.Repository;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

@Repository
public interface CmdbDiskStandardDeviceStandardRelateRepository extends JpaRepository<CmdbDiskStandardDeviceStandardRelate, Integer>, JpaSpecificationExecutor<CmdbDiskStandardDeviceStandardRelate> {
    List<CmdbDiskStandardDeviceStandardRelate> findAllByIdIn(List<Long> id);

    @Transactional
    @Modifying
    @Query(value = "update t_cmdb_disk_standard_device_standard_relate set is_delete = :deleted where id in :codes ", nativeQuery = true)
    void updateIsDeleteByCodes(Integer deleted, List<Integer> codes);

    @Transactional
    @Modifying
    @Query(value = "update t_cmdb_disk_standard_device_standard_relate set is_delete = :deleted where device_standard_code = :deviceStandardCode ", nativeQuery = true)
    void updateIsDeleteByDeviceStandardCode(Integer deleted, String deviceStandardCode);

    List<CmdbDiskStandardDeviceStandardRelate> findByDeviceStandardCodeAndIsDelete(String deviceStandardCode, Integer isDelete);


//    Page<CmdbDiskStandardDeviceStandardRelate> searchByParam(Pageable pageable, CmdbDiskStandardDeviceStandardRelate paramSearchDto);
}

